<template>
  <div class="common-edit">
    <script id="simpleUE" type="text/plain" style="width: 100%"></script>
  </div>
</template>
<script>
    export default {
        name: "ueInbox",
        data() {
            return {
                editor: null,
                defaultConfig: {

                }
            };
        },
        props: ['catchData', 'config'], // 接收父组件的方法
        mounted() {
            const _this = this;
            let config = Object.assign({}, this.defaultConfig, this.config)
            this.editor = UE.getEditor('simpleUE', config); // 初始化UE
            this.editor.addListener("ready", function () {
                _this.$emit('ready');
            });
            this.editor.addListener("contentChange", () => {
                this.catchData(this.editor.getContent());
            });
        },
        methods: {
            insertEditor(val) {
                const _this = this;
                _this.editor.setContent(val);
            }
        },
        beforeDestroy() {
            this.editor.destroy();
        }
    };
</script>
